<script setup>
import { onMounted, nextTick, ref, reactive, watch } from "vue";
import * as echarts from "echarts";
import Menu from "../components/mylement/Menu.vue";
import { userInfo } from "../stores/default";
import { useRouter } from "vue-router";
// {/* <el-icon><ArrowDown /></el-icon> */}
import { ArrowDown } from "@element-plus/icons-vue";
import provider from "../stores/provider.js";
const router = useRouter();
const user = userInfo();

const { title } = provider;

onMounted(() => {
  // initTitle()
});

const routerList = ref([]);

const loginOut = () => {
  // document.cookie = "userId=; Max-Age=0";
  // router.push('/login')
  // 清空sessionStorage
  sessionStorage.clear();
  router.push("/login");
};
</script>

<template>
  <div class="headerView">
    <div id="headerContain">
      <img src="../assets//img/帆船.png" alt="" />
      <div id="title_chart">{{ title }}</div>

      <Menu />
      <div style="margin-left: 40px">
        <el-avatar
          src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"
        />
      </div>
      <!-- <el-button style="margin-left: 20px;" size="default" @click="loginOut">退出</el-button> -->
      <el-dropdown style="margin-left: 10px; cursor: pointer">
        <span class="el-dropdown-link">
          {{ user.getValue.username }}
          <el-icon class="el-icon--right">
            <ArrowDown />
          </el-icon>
        </span>
        <template #dropdown>
          <el-dropdown-menu style="width: 100px">
            <el-dropdown-item @click="loginOut">退出</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>

      <!-- 菜单 -->
      <!-- <a-menu v-model:selectedKeys="current" mode="horizontal">
        <a-menu-item key="mail">
          <template #icon>
            <mail-outlined />
          </template>
          首页
        </a-menu-item>
        <a-menu-item key="app">
          <template #icon>
            <appstore-outlined />
          </template>
          灾害预警
        </a-menu-item>
        <a-sub-menu key="sub1">
          <template #icon>
            <setting-outlined />
          </template>
          <template #title>海洋预报</template>
          <a-menu-item-group title="Item 1">
            <a-menu-item key="setting:1">Option 1</a-menu-item>
            <a-menu-item key="setting:2">Option 2</a-menu-item>
          </a-menu-item-group>
          <a-menu-item-group title="Item 2">
            <a-menu-item key="setting:3">Option 3</a-menu-item>
            <a-menu-item key="setting:4">Option 4</a-menu-item>
          </a-menu-item-group>
        </a-sub-menu>
        <a-menu-item key="alipay">
          生态预警
        </a-menu-item>
      </a-menu> -->
    </div>
  </div>
</template>

<style lang="less" scoped>
.headerView {
  height: var(--nv-height);
  width: 100%;
  // position: fixed;
  border-bottom: 1px solid var(--bd-color);
  background-color: var(--nv-bg-color);
  // z-index: var(--nv-z-index);
  z-index: 100;
  padding: 0 15px;

  #headerContain {
    display: flex;
    align-items: center;
    height: 100%;
    width: 100%;

    #title_chart {
      // width: 200px;
      margin-left: 10px;
      display: flex;
      align-items: center;
      font-size: 30px;
      color: var(--title-color);
      font-family: "钉钉进步体", sans-serif;
    }

    // :deep(.ant-menu-root) {
    //   width: 800px;
    // }

    .Menu {
      // margin-left: 30px;
      margin-left: auto;
      margin-right: 10px;
    }

    img {
      height: 60px;
    }
  }
}
</style>
